/*
 * BookTest.java
 *
 * This program demonstrates the use of Book class to create
 * a repository of books.
 *

 */

package com.javacore.day4.bookdetails;

import java.util.Scanner;

/**
 * BookTest class uses the Book class to create a repository of books
 * and perform various operations on it.
 * @author 
 */
public class BookTest {
    
    /** Creates a new instance of BookTest */
    public BookTest() {
    }
    
    /**
     * This is the entry point of the application.
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        // Variable to store the option selected by the user
        int choice;
        Scanner input = new Scanner(System.in);
        
        // Create an instance of Book class
        Book objBook = new Book();
        
        // Iterate until the user chooses to exit the application
        do {
            System.out.println("\nWelcome to E-Repository.\n" +
                    "Select the operation you want to perform:");
            System.out.println("******************************************");
            System.out.println("1. Add book to the repository.");
            System.out.println("2. Search book by ISBN number.");
            System.out.println("3. Search book by Year.");
            System.out.println("4. Display book details.");
            System.out.println("5. Exit.");
            System.out.println("******************************************\n");
            choice = input.nextInt();
            
            // Invoke the methods of the Book class to perform the operation
            // selected by the user   ascending
            switch(choice){
                case 1:
                    objBook.addBook();
                    break;
                case 2:
                    objBook.searchByIsbn();
                    break;               
                case 3:
                    objBook.searchByYear();
                    break;
                case 4:
                    objBook.displayBooks();
                    break;
                case 5:
                    break;
                default:
                    System.out.println("Invalid choice!");
                    break;
            }
        } while(choice != 5);
    }
}
